<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>预约管理</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="icon" type="image/png" href="/resources/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="/resources/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
    <script src="/resources/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/resources/css/amazeui.min.css"/>
    <link rel="stylesheet" href="/resources/css/amazeui.datatables.min.css"/>
    <link rel="stylesheet" href=/resources/css/amazeui.chosen.css"/>
    <link rel="stylesheet" href="/resources/css/app.css">
    <script src="/resources/js/jquery.min.js"></script>
    <script src="/resources/js/amazeui.chosen.min.js"></script>
</head>

<body data-type="widgets">
<script src="/resources/js/theme.js"></script>
<div class="am-g tpl-g">

    <%--头部开始--%>
    <%@include file="header.jsp" %>
    <%--头部结束--%>

    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">
        <div class="row-content am-cf">
            <div class="row">
                <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                    <div class="widget am-cf">
                        <%-- 消息 --%>
                        <div class="container-fluid am-cf">
                            <div class="row">
                                <div class="am-u-sm-12 am-u-md-12 am-u-lg-9">
                                    <div class="page-header-heading"><span
                                            class="am-icon-smile-o page-header-heading-icon"></span> 预约
                                        <small>Subscribe information management</small>
                                    </div>
                                    <p class="page-header-description">对预约信息进行管理操作。</p>
                                </div>
                                <div class="am-u-lg-3 tpl-index-settings-button">
                                    <%--<button type="button" class="page-header-button"><span class="am-icon-paint-brush"></span> 设置</button>--%>
                                </div>
                            </div>
                        </div>
                        <%-- 表格 --%>
                        <div class="widget-body  am-fr">

                            <!-- 用户表开始 -->
                            <div class="am-u-sm-12 tableDiv">
                                <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
                                    <thead>
                                    <tr>
                                        <th class="am-text-center">用户名</th>
                                        <th class="am-text-center">联系电话</th>
                                        <th class="am-text-center">预约到店时间</th>
                                        <th class="am-text-center">宝宝姓名</th>
                                        <th class="am-text-center">当前状态</th>
                                        <th class="am-text-center">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody class="am-text-center">
                                    <!-- more data -->
                                    <c:forEach items="${pageInfo.list }" var="illCase">
                                        <tr>
                                            <td>${illCase.userName}</td>
                                            <td>${illCase.userTel}</td>
                                            <td>
                                                ${fn:substring(illCase.visitDate, 0, 10)}
                                            </td>
                                            <td>${illCase.babyName}</td>
                                            <td>
                                                <c:choose>
                                                    <c:when test="${illCase.illCaseState == 0}">等待采集数据</c:when>
                                                    <c:when test="${illCase.illCaseState == 1}">等待开单</c:when>
                                                    <c:when test="${illCase.illCaseState == 2}">开单完成</c:when>
                                                    <c:when test="${illCase.illCaseState == 3}">等待会诊</c:when>
                                                    <c:when test="${illCase.illCaseState == 4}">会诊完成</c:when>
                                                    <c:when test="${illCase.illCaseState == 5}">预约中</c:when>
                                                </c:choose>
                                            </td>
                                                <%--<td>
                                                    ${fn:substring(b.infoInputDate, 0, 10)}
                                                </td>--%>
                                            <td>
                                                <c:if test="${illCase.illCaseState == 0}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="">
                                                        <span class="am-icon-edit"></span> 采集数据
                                                    </button>
                                                </c:if>
                                                <c:if test="${illCase.illCaseState == 1}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="chackPres()" data-am-modal="{target: '#presModal' , width: 600}">
                                                        <span class="am-icon-edit"></span> 进入开单
                                                    </button>
                                                </c:if>
                                                <c:if test="${illCase.illCaseState == 2}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="">
                                                        <span class="am-icon-edit"></span> 进入会诊
                                                    </button>
                                                </c:if>
                                                <c:if test="${illCase.illCaseState == 5}">
                                                    <button type="button" class="am-btn am-btn-xs am-btn-success" onclick="window.location.href='/process/prefirst?id=${illCase.illCaseId}'">
                                                        <span class="am-icon-edit"></span> 进入流程
                                                    </button>
                                                </c:if>
                                                <button type="button" class="am-btn am-btn-xs am-btn-secondary" onclick="checkVipInfo('${illCase.userId}')" data-am-modal="{target: '#formModel', width: 900}">
                                                    <span class="am-icon-eye"></span> 查看会员数据
                                                </button>
                                                <button type="button" class="am-btn am-btn-xs am-btn-danger" onclick="deleteCase('${illCase.illCaseId}','${illCase.userTel}')">
                                                    <span class="am-icon-delicious"></span> 驳回预约
                                                </button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                            <!-- 用户表结束 -->

                            <!-- 分页开始 -->
                            <div class="am-u-lg-12 am-cf pageInfoTotal">

                                <!-- 分页文字信息，其中分页信息都封装在pageInfo中 -->
                                <div class="col-md-6 ">
                                    当前第：${pageInfo.pageNum }页，总共：${pageInfo.pages }页，总共：${pageInfo.total }条记录
                                </div>
                                <div class="am-fr">
                                    <ul class="am-pagination tpl-pagination">
                                        <!-- 首页 -->
                                        <li><a href="/illCaseController/getillcase?pn=1&status=${status}">首页</a></li>
                                        <!-- 上一页 -->
                                        <c:if test="${pageInfo.hasPreviousPage }">
                                            <li>
                                                <a href="/illCaseController/getillcase?pn=${pageInfo.pageNum-1 }&status=${status}"
                                                   aria-label="Previous">
                                                    <span aria-hidden="true">&laquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 循环遍历连续显示的页面，若是当前页就高亮显示，并且没有链接 -->
                                        <c:forEach items="${pageInfo.navigatepageNums }" var="page_Num">
                                            <c:if test="${page_Num == pageInfo.pageNum }">
                                                <li class="am-active"><a
                                                        href="/illCaseController/getillcase?status=5&pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                            <c:if test="${page_Num != pageInfo.pageNum }">
                                                <li>
                                                    <a href="/illCaseController/getillcase?status=${status}&pn=${page_Num }">${page_Num }</a>
                                                </li>
                                            </c:if>
                                        </c:forEach>
                                        <!-- 下一页 -->
                                        <c:if test="${pageInfo.hasNextPage }">
                                            <li>
                                                <a href="/illCaseController/getillcase?status=${status}&pn=${pageInfo.pageNum+1}"
                                                   aria-label="Next">
                                                    <span aria-hidden="true">&raquo;</span>
                                                </a>
                                            </li>
                                        </c:if>
                                        <!-- 末页 -->
                                        <li><a href="/illCaseController/getillcase?status=${status}&pn=${pageInfo.pages}">末页</a></li>
                                    </ul>
                                </div>
                            </div>
                            <!-- 分页结束 -->
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 查看会员信息模态框开始 -->
    <div class="am-modal am-modal-no-btn" tabindex="-1" id="formModel">
        <div class="am-modal-dialog">
            <div class="am-modal-bd" style="padding: 2px;">
                <div class="row">
                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf" style="margin: 0;">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl"><h2>会员信息查看</h2></div>
                                <div class="widget-function am-fr">
                                    <a href="javascript: void(0)" class="am-close am-close-spin clearForm"
                                       data-am-modal-close>&times;</a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">
                                <form class="am-form tpl-form-border-form tpl-form-border-br" id="addUserForm">

                                    <!-- 数据库主键(隐藏) -->
                                    <div class="am-form-group am-hide">
                                        <label class="am-u-sm-3 am-form-label">userId</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="id" class="am-form-field tpl-form-no-bg Id">
                                            <input type="text" name="userId"
                                                   class="am-form-field tpl-form-no-bg userId">
                                        </div>
                                        <div class="am-u-sm-3">
                                            <small>不可编辑！</small>
                                        </div>
                                    </div>

                                    <!-- 会员、学员 -->
                                    <%--  <div class="am-form-group">
                                          <label class="am-u-sm-3 am-form-label">用户身份</label>
                                          <div class="am-u-sm-6">
                                              <div class="am-form-group">
                                                  <label class="am-radio-inline">
                                                      <input class="reserve1" type="radio" name="reserve1" value="0"
                                                             checked="checked"> 会员
                                                  </label>
                                                  <label class="am-radio-inline">
                                                      <input class="reserve1" type="radio" name="reserve1" value="1"
                                                             onchange=""> 学员
                                                  </label>
                                              </div>
                                          </div>
                                          <div class="am-u-sm-3">
                                              <small style="color: green"></small>
                                          </div>
                                      </div>--%>

                                    <!-- 姓名 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">用户名</label>
                                        <div class="am-u-sm-6">
                                            <input maxlength="18" type="text" name="userName"
                                                   class="tpl-form-input userName"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>
                                    

                                    <!-- 宝宝姓名 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝姓名</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyName"
                                                   class="am-form-field tpl-form-no-bg BabyName"
                                                   placeholder="小宝贝" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝档案编号 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝档案编号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="fileNo"
                                                   class="am-form-field tpl-form-no-bg fileNo"
                                                   placeholder="123123123123" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝性别 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝性别</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babySex"
                                                   class="am-form-field tpl-form-no-bg babySex"
                                                   placeholder="男" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝年龄 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝年龄</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyAge"
                                                   class="am-form-field tpl-form-no-bg babyAge"
                                                   placeholder="1" readonly>周岁
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝体重 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝体重</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyWeight"
                                                   class="am-form-field tpl-form-no-bg babyWeight"
                                                   placeholder="3000" readonly>克
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 宝宝身高 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">宝宝身高</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="babyHeight"
                                                   class="am-form-field tpl-form-no-bg babyHeight"
                                                   placeholder="90" readonly>cm
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 会员编号 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">会员编号</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="vipNo"
                                                   class="am-form-field tpl-form-no-bg vipNo"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 会员等级 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">会员等级</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="vipCategory"
                                                   class="am-form-field tpl-form-no-bg vipCategory"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 所属分店 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">所属分店</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="branname"
                                                   class="am-form-field tpl-form-no-bg branname"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 余额 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">余额</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="balance"
                                                   class="am-form-field tpl-form-no-bg balance"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 剩余消费次数 -->
                                    <div class="am-form-group">
                                        <label class="am-u-sm-3 am-form-label">剩余消费次数</label>
                                        <div class="am-u-sm-6">
                                            <input type="text" name="remainTime"
                                                   class="am-form-field tpl-form-no-bg remainTime"
                                                   placeholder="" readonly>
                                        </div>
                                        <div class="am-u-sm-3">
                                        </div>
                                    </div>

                                    <!-- 按钮 -->
                                    <div class="am-form-group">
                                        <div class="am-u-sm-12">
                                            <button type="button"
                                                    class="am-btn am-btn-primary tpl-btn-bg-color-success  clearForm"
                                                    data-am-modal-close=""><i class="am-icon-close"></i> 关闭
                                            </button>
                                        </div>
                                    </div>

                                </form>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 整个表单结束 -->
            </div>
        </div>
    </div>
    <!-- 查看会员信息模态框结束 -->



        <!-- 查看处方明细模态框开始 -->
        <div class="am-modal am-modal-no-btn" tabindex="-1" id="presModal">
            <div class="am-modal-dialog">
                <div class="am-modal-bd" style="padding: 2px;">
                    <div class="row">
                        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                            <div class="widget am-cf" style="margin: 0;">
                                <div class="widget-head am-cf">
                                    <div class="widget-title am-fl"><h2>会员信息查看</h2></div>
                                    <div class="widget-function am-fr">
                                        <a href="javascript: void(0)" class="am-close am-close-spin clearForm"
                                           data-am-modal-close>&times;</a>
                                    </div>
                                </div>
                                <div class="widget-body am-fr">
                                    <!-- 用户表开始 -->
                                    <div class="am-u-sm-12 tableDiv">
                                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black">
                                            <thead>
                                            <tr>

                                                <th class="am-text-center">类型</th>
                                                <th class="am-text-center">商品\穴位名称与用量</th>
                                                <th class="am-text-center">单价</th>
                                            </tr>
                                            </thead>
                                            <tbody class="am-text-center">
                                                <tr>
                                                    <td>商品</td>
                                                    <td>大白菜 1 袋</td>
                                                    <td>20元</td>
                                                </tr>
                                                <tr>
                                                    <td>穴位</td>
                                                    <td>太阳穴 2 次</td>
                                                    <td>20元</td>
                                                </tr>
                                                <tr>
                                                    <td>总价</td>
                                                    <td><input type="text" value="40">元</td>
                                                </tr>
                                            <!-- more data -->
                                            </tbody>
                                        </table>
                                    </div>
                                    <!-- 用户表结束 -->
                                    <!-- 按钮 -->
                                    <div class="am-form-group">
                                        <div class="am-u-sm-12">
                                            <button type="button"
                                                    class="am-btn am-btn-primary tpl-btn-bg-color-success  clearForm"
                                                    data-am-modal-close=""><i class="am-icon-close"></i> 关闭
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- 整个表单结束 -->
                </div>
            </div>
        </div>
        <!-- 查看处方明细模态框结束 -->



</div>

<script src="/resources/js/amazeui.min.js"></script>
<script src="/resources/js/amazeui.datatables.min.js"></script>
<script src="/resources/js/dataTables.responsive.min.js"></script>
<script src="/resources/js/app.js"></script>
<script src="/resources/jsutlis/fileutli.js"></script>
<script>

function checkVipInfo(uid) {
    var formdata = new FormData();
    formdata.append("userId",uid);
    $.ajax({
        url: "/vipInfoController/findOneVipInfo",
        type: 'POST',
        cache: false,
        data: formdata,
        async: false,
        processData: false,
        contentType: false
    }).done(function (res) {
        var vipIdForm = new FormData();
        vipIdForm.append("vipId",res.vipinf.vipId);
        $(".vipNo").val(res.vipinf.vipNo);
        $.ajax({
            url: "/vipCardController/findOneVipCard",
            type: 'POST',
            cache: false,
            data: vipIdForm,
            async: false,
            processData: false,
            contentType: false
        }).done(function (data) {
            $(".vipCategory").val(data.vip.vipName);
            if(data.vip.vipName == "体验卡"){
                $(".remainTime").val(res.vipinf.remainTime);
            }
        });
        $(".balance").val(res.vipinf.balance);
        var chargeTime = res.vipinf.chargeDtae;
        $(".chargeDtae").val(timestampToTime(chargeTime));
        if(res.vipinf.state == 0){
            $(".state").val("未激活");
        }else if(res.vipinf.state ==1 ){
            $(".state").val("已激活")
        }

        var branchesId = new FormData();
        branchesId.append("branId",res.vipinf.branId);
        $.ajax({
            url: "/branchesController/findOneBranches",
            type: 'POST',
            cache: false,
            data: branchesId,
            async: false,
            processData: false,
            contentType: false
        }).done(function (oneBran) {
            $(".branname").val(oneBran.bran.branName);
        });


    });
}

function deleteCase(id,tel) {
    var formdata = new FormData();
    formdata.append("illCaseId",id);
    $.ajax({
        url: "/illCaseController/deleteIllCase",
        type: 'POST',
        cache: false,
        data: formdata,
        async: false,
        processData: false,
        contentType: false
    }).done(function(res){
       if(res != undefined && res != null && res != ""){
           alert("已驳回改预约，请致电客户通知。电话号码："+tel);
           window.location.href="/illCaseController/getillcase";
       }
    });
}

</script>
</body>

</html>